Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add minimal windows support #3

Closed
wants to merge 1 commit into from

Conversation

dmanto
Copy link

@dmanto dmanto commented Apr 4, 2021

This should fix all pending claims from your review. Rebased from new master branch (PR#1 was based on windows branch, that's why I closed it and created this new one).

  • Added function listenAddress() to allow portable server start (string with either 'http://*?fd=3' or 'http://:'.
  • Added env variable MOJO_SERVER_STARTER_AVOID_FDPASS to avoid fd pass of listening socket when it is not supported by the server. (for example, does Dancer support listening to fd=3 ?. Didn't find how to). Python / RoR / PHP platforms probably have other ways, not sure about that.
  • Modified README to document new functionalities.
  • Modified test/support/server.js to support portable url, plus delayed start to mock slow server.
  • Changed github CI action strategy to test MOJO_SERVER_STARTER_AVOID_FDPASS 0 and 1 cases.
  • Added ECONNREFUSED test for server slower than connectTimeout mS

Related to issue #1

listenAddress () {
if (this._useFdPass) return 'http://*?fd=3';
return this.url();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're still missing the point. This module is not meant to be Mojolicious specific at all. This could be a generic feature that any other web framework could use just the same.

const connection = net.connect(port, resolve);
connection.on('error', err => {
if (err.code === 'ECONNREFUSED' && new Date() < timeToStop) setTimeout(loop, retryTime);
else resolve(); // this is intented: don't reject, just stop delaying
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of my requirements was that it rejects on errors. Are you sure you don't just want to make your own module?

@@ -44,6 +44,7 @@ class Server extends EventEmitter {
this._process = undefined;
this._exitHandlers = [];
this._exit = undefined;
this._useFdPass = process.env.MOJO_SERVER_STARTER_AVOID_FDPASS ? false : process.platform !== 'win32';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Mojo specific code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And let the users decide if they want to use a file descriptor or not. Hidden magic only makes it harder to write portable code.

@@ -1,3 +1,3 @@
node_modules
package-lock.json

.vscode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to the rest of the PR.

@kraih
Copy link
Member

kraih commented Apr 5, 2021

Opening a second PR feels like you're dismissing all my previous reviews. I've tried very hard to tell you exactly what i expect from this feature. And you still do the opposite intentionally (as illustrated by comments). I don't think both of us want the same from this module, so perhaps you would be better off just releasing your own Windows specific one instead.

setTimeout(
() => resolve(server.listen(listen)),
delay)
}))();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had renamed the test server to server_fd.js the other day specifically so the code doesn't have to get messy for new features.

@kraih
Copy link
Member

kraih commented Apr 5, 2021

Normally i would flag this PR as work in progress and wait for your response/changes, but since you close those anyway i'll do the same now.

@kraih kraih closed this Apr 5, 2021
if (this._useFdPass) resolve();
else {
const now = new Date();
const timeToStop = new Date(now.getTime() + connectTimeout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even my feedback on the unused now constant from the previous PR you've just dismissed without changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants